// eslint-disable-next-line no-unused-vars
import VXETable, { Column } from 'vxe-table'
import createBem from '@Components/assets/js/utils/bem'
import { tableNamespace } from '../../../config'
import { TRADE_FROM_TYPE } from '@Components/assets/js/config'
import './index.scss'

const Bem = createBem(`${tableNamespace}__store-name`)

VXETable.renderer.add('StoreName', {
  renderDefault(h, renderOpts, params) {
    const { row, column } = params

    //店铺类型字段
    const { options = {} } = renderOpts
    const { typeField } = options
    let iconName = ''
    switch (row[typeField]) {
      case TRADE_FROM_TYPE.TY:
        iconName = 'icon-xianxiadianpu xianxia-font-color'
        break
      case TRADE_FROM_TYPE.TB:
        iconName = 'icon-taobao taobao-font-color'
        break
      case TRADE_FROM_TYPE.JD:
        iconName = 'icon-jingdong jingdong-font-color'
        break
      case TRADE_FROM_TYPE.PDD:
        iconName = 'icon-pinduoduo pinduoduo-font-color'
        break
      case 6:
        iconName = 'icon-douyin douyin-font-color'
        break
      default:
        iconName = ''
        break
    }

    return [
      <div class={Bem()}>
        {iconName && <i class={`iconfont default-icon-color ${iconName}`} />}
        <span>{row[column.property]}</span>
      </div>
    ]
  }
})

/** @type { Column } */
export const options = {
  showOverflow: 'tooltip',
  align: 'left'
}
